package com.coai.gateway.controller

import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * 熔断降级处理
 */
@RestController
@RequestMapping("/fallback")
class FallbackController {
    
    @GetMapping("/ai")
    fun aiFallback(): ResponseEntity<Map<String, Any>> {
        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
            .body(mapOf(
                "success" to false,
                "message" to "AI服务暂时不可用，请稍后重试",
                "code" to 503
            ))
    }
    
    @GetMapping("/default")
    fun defaultFallback(): ResponseEntity<Map<String, Any>> {
        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
            .body(mapOf(
                "success" to false,
                "message" to "服务暂时不可用，请稍后重试",
                "code" to 503
            ))
    }
}
